/**
 * 
 */
package playGround.square;


import static org.junit.Assert.assertEquals;

import java.math.BigDecimal;

import org.junit.Before;
import org.junit.Test;

import exceptions.OverflowException;

/**
 * @author Niels Claeys, Maarten Christiaen
 *
 */
public class ScaleTest {

	/**
	 * @throws java.lang.Exception
	 */
	@Before
	public void setUp() throws Exception {
	}
	@Test
	public void testScaleKelvin(){
		int value = Scale.changeScale(Scale.KELVIN, Scale.CELCIUS, 0);
		assertEquals(-273,value);
	}
	@Test
	public void testScaleFahrenheit(){
		int value = Scale.changeScale(Scale.CELCIUS, Scale.FAHRENHEIT, 0);
		assertEquals(32,value);
	}
	@Test
	public void testScaleCelcius(){
		int value = Scale.changeScale(Scale.CELCIUS, Scale.KELVIN, 20);
		assertEquals(293,value);
	}
	@Test(expected=OverflowException.class)
	public void testScaleOverFlowFahrenheit(){
		long value = new BigDecimal(2147483647).divide(new BigDecimal(9),2).multiply(new BigDecimal(6)).longValue();
		Scale.changeScale(Scale.CELCIUS, Scale.FAHRENHEIT, (int) value);
	}
	@Test(expected=OverflowException.class)
	public void testScaleOverFlowKelvin(){
		long value = new BigDecimal(2147483647).subtract(new BigDecimal(200)).longValue();
		Scale.changeScale(Scale.CELCIUS, Scale.KELVIN, (int) value);
	}
	
}
